import 'package:flutter/material.dart';
import 'package:simple_animations/simple_animations.dart';

enum AniProps { width, height, color, color2 }

class AnimatedBackground extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final tween = MultiTween<AniProps>()
      ..add(
        AniProps.color,
        ColorTween(begin: Color(0xffD38312), end: Colors.lightBlue.shade900),
        Duration(seconds: 3),
      )
      ..add(
        AniProps.color2,
        ColorTween(begin: Color(0xffA83279), end: Colors.blue.shade600),
        Duration(seconds: 3),
      )
      ..add(
        AniProps.color,
        ColorTween(begin: Color(0xffA83279), end: Colors.lightBlue.shade900),
        Duration(seconds: 3),
      );

    return LoopAnimation<MultiTweenValues<AniProps>>(
      tween: tween,
      duration: tween.duration,
      builder: (context, child, value) {
        return Container(
          decoration: BoxDecoration(
            gradient: LinearGradient(
              begin: Alignment.topCenter,
              end: Alignment.bottomCenter,
              colors: [
                value.get(AniProps.color),
                value.get(AniProps.color2),
              ],
            ),
          ),
        );
      },
    );
  }
}
